using FineCollection.Test;
using FineCollection.Intf;

using NUnit.Framework;

namespace FineCollection.Const
{


    [TestFixture]
    public class ConstHashSet_test
    {

        #region CONSTRUCTING

        [Test]
        public void Test_DuplicatedItems1()
        {
            var set = CC1.HashSetOf(111L, 333L, 333L, 333L, 333L, 555L);

            set.Contains(111L)._true_();
            set.Contains(333L)._true_();
            set.Contains(555L)._true_();

            long[] array = set.ToArray();
            System.Array.Sort(array);
            array._array_(111L, 333L, 555L);

            set.Count._equals_(3);
        }


        [Test]
        public void Test_DuplicatedItems2()
        {
            var set = CC1.HashSetOf(777L, 999L, 222L, 777L);

            set.Contains(777L)._true_();
            set.Contains(999L)._true_();
            set.Contains(222L)._true_();

            long[] array = set.ToArray();
            System.Array.Sort(array);
            array._array_(222L, 777L, 999L);

            set.Count._equals_(3);
        }
       

        [Test]
        public void Test_DuplicatedItems3()
        {
            string[] strings = new[]
                                   {
                                       System.TimeZone.CurrentTimeZone.ToString(),
                                       System.TimeZone.CurrentTimeZone.ToString(),
                                       "labuda"
                                   };
            var set = CC1.HashSetOf(strings);

            set.Contains(strings[0])._true_();
            set.Contains("labuda")._true_();

            set.Count._equals_(2);
        }
       


        #endregion



        #region INDEX OF

        [Test]
        public void Test_IndexOfInEmpty()
        {
            var set = CC1.HashSetOf<ulong>();

            set.IsEmpty       ._true_();

            set.IndexOf(111L) ._equals_(int.MinValue);
            set.IndexOf(0L)   ._equals_(int.MinValue);
        }


        [Test]
        public void Test_IndexOfIn3()
        {
            var set = CC1.HashSetOf(333333L, 555555L, 777777L);

            set[ set.IndexOf(333333L) ] ._equals_(333333L);
            set[ set.IndexOf(555555L) ] ._equals_(555555L);
            set[ set.IndexOf(777777L) ] ._equals_(777777L);

            set.IndexOf(999999L)   ._equals_(int.MinValue);
            set.IndexOf(000000L)   ._equals_(int.MinValue);
        }


        [Test]
        public void Test_IndexOfIn3Strings()
        {
            var set = CC1.HashSetOf("moskvich", "zhiguli", "volga");

            set[ set.IndexOf("moskvich") ]   ._equals_("moskvich");
            set[ set.IndexOf("zhiguli")  ]   ._equals_("zhiguli");
            set[ set.IndexOf("volga")    ]   ._equals_("volga");

            set.IndexOf("zaporozhets") ._equals_(int.MinValue);
        }


        [Test]
        public void Test_IndexOfNullInEmpty()
        {
            var set = CC1.HashSetOf<string>();

            set.IndexOf((string)null)._equals_(int.MinValue);
            set.IndexOf("")._equals_(int.MinValue);
        }


        [Test]
        public void Test_IndexOfNullInNonEmpty()
        {
            var set = CC1.HashSetOf("moskvich", "zhiguli", "volga");

            set.IndexOf((string)null)._equals_(int.MinValue);
            set.IndexOf("")._equals_(int.MinValue);
        }



        #endregion




    }


}